import request from '@/utils/request'

// 流程模型列表
export function getProcessModelList() {
  return request({
    url: '/workflow/model/modelList',
    method: 'get',
  })
}
// 保存流程模型
export function saveProcessModel(data) {
  return request({
    url: '/workflow/model/save',
    method: 'post',
    data: data
  })
}
// 部署流程模型
export function deployProcessModel(id,xmlType) {
  return request({
    url: '/workflow/model/deploy',
    method: 'post',
    data: {str1:id,str2:xmlType}
  })
}
// 删除流程模型
export function deleteProcessModel(ids) {
  return request({
    url: '/workflow/model/delete',
    method: 'delete',
    data: { str: ids }
  })
}

// 删除流程定义
export function deleteProcessDefine(deploymentId) {
  return request({
    url: '/workflow/define/delete',
    method: 'delete',
    data: { str: deploymentId }
  })
}

// 检查流程定义资源文件是否存在
export function checkProcessDefineResource(processDefineId) {
  return request({
    url: '/workflow/define/checkResource',
    method: 'get',
    params: { processDefinitionId: processDefineId }
  })
}
// 查询流程历史版本
export function processDefineHistoryList(processDefinitionKey) {
  return request({
    url: '/workflow/define/historyList',
    method: 'get',
    params: { processDefinitionKey: processDefinitionKey }
  })
}
// 预览流程定义资源
export function viewProcessDefine(processDefineId) {
  return request({
    url: '/workflow/define/view',
    method: 'get',
    responseType: 'blob',
    params: { processDefinitionId: processDefineId }
  })
}
// 上传流程定义
export function uploaderProcessDefine(fileId) {
  return request({
    url: '/workflow/define/deploy',
    method: 'post',
    data: { str: fileId }
  })
}
// 发起流程定义
export function startProcessDefine(processDefineId) {
  return request({
    url: '/workflow/define/start',
    method: 'post',
    data: { str: processDefineId }
  })
}

// 执行中流程图
export function getActiveProcessImage(processInstanceId,taskId) {
  return request({
    url: '/workflow/example/activeProcessImage',
    method: 'get',
    responseType: 'blob',
    params: { processInstanceId: processInstanceId,taskId:taskId }
  })
}
// 流程参数
export function getProcessParam(processInstanceId,taskId) {
  return request({
    url: '/workflow/example/processParam',
    method: 'get',
    params: { processInstanceId: processInstanceId,taskId: taskId }
  })
}
// 流程批注
export function processCommentList(processInstanceId,taskId) {
  return request({
    url: '/workflow/example/commentList',
    method: 'get',
    params: { processInstanceId: processInstanceId,taskId: taskId }
  })
}

// 删除流程实例
export function deleteProcessInstance(processInstanceIds) {
  return request({
    url: '/workflow/example/deleteProcessInstance',
    method: 'post',
    data: { str: processInstanceIds }
  })
}
// 挂起流程实例
export function pauseProcessInstance(processInstanceIds) {
  return request({
    url: '/workflow/example/pauseProcessInstance',
    method: 'post',
    data: { str: processInstanceIds }
  })
}
// 恢复流程实例
export function continueProcessInstance(processInstanceIds) {
  return request({
    url: '/workflow/example/continueProcessInstance',
    method: 'post',
    data: { str: processInstanceIds }
  })
}
// 签收任务
export function homeTask() {
  return request({
    url: '/workflow/myTask/myUnFinishList',
    method: 'post',
    data: { home: true }
  })
}
// 签收任务
export function claimTask(taskId) {
  return request({
    url: '/workflow/myTask/claimTask',
    method: 'post',
    data: { str: taskId }
  })
}
// 取消签收任务
export function discardTask(taskId) {
  return request({
    url: '/workflow/myTask/discardTask',
    method: 'post',
    data: { str: taskId }
  })
}

// 获得任务处理url
export function getTaskDealUrl(taskId,urlType) {
  return request({
    url: '/workflow/myTask/getTaskDealUrl',
    method: 'get',
    params: { taskId: taskId,urlType: urlType }
  })
}

// 查询任务的候选人列表
export function listTaskCandidate(taskId) {
  return request({
    url: '/workflow/task/listTaskCandidate',
    method: 'get',
    params: { taskId: taskId }
  })
}

// 指派任务
export function taskCandidate(taskId,orgId) {
  return request({
    url: '/workflow/task/taskCandidate',
    method: 'post',
    data: { str1: taskId, str2: orgId }
  })
}
// 添加候选人
export function addTaskCandidate(taskId,orgIds) {
  return request({
    url: '/workflow/task/addTaskCandidate',
    method: 'post',
    data: { str: taskId, arr: orgIds }
  })
}

// 删除候选人
export function deleteTaskCandidate(taskId,orgId) {
  return request({
    url: '/workflow/task/deleteTaskCandidate',
    method: 'post',
    data: { str1: taskId, str2: orgId }
  })
}
// 任务处理页面初始化
export function dealTaskInit(taskId) {
  return request({
    url: '/workflow/myTask/dealTaskInit',
    method: 'get',
    params: { taskId: taskId}
  })
}
// 任务查看页面初始化
export function viewTaskInit(taskId) {
  return request({
    url: '/workflow/myTask/viewTaskInit',
    method: 'get',
    params: { taskId: taskId}
  })
}
// 提交任务
export function submitTask(url,data) {
  return request({
    url: url,
    method: 'post',
    data: data
  })
}
